<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/jsphead.jsp" %>
<html>
<head>
	<title> ${appTitle} - <s:property value="book.name"/></title>
	<%@ include file="/common/meta.jsp" %>
	<link rel="stylesheet" type="text/css" href="css/default.css"/>
	<style type="text/css">
		body,div,span,td{font-size:14px;}
		div{margin:0px;padding:0px;margin-left:auto;margin-right:auto;}
		#tabbar{text-align:left;margin-top:16px;height:26px;}
		.tab{
			float:left;background-color:#e4d7ca;line-height:25px;
			padding:0px 8px; margin-right:3px;cursor:pointer;
			border-left: 1px solid #aaa;border-top: 1px solid #aaa;border-right: 1px solid #aaa;
		}
		.tab-active{font-weight:bold;background-color:#cbb198;cursor:default;color:#000;}
		#container{
			clear:both;text-align:left;line-height:23px;font-size:14px;
			overflow:auto;border:1px solid #aaa;
			padding: 5px;
		}
	</style>
	<script type="text/javascript" src="jslib/jquery-1.4.2.min.js"></script>
	<script type="text/javascript">
		$(function(){
			//给引用的书籍添加链接，必须在添加链接后才能设置标签页，否则有误。
			markBookRefers();
			var h = $(window).height() 
				  - $("#head").outerHeight()
				  - $("#tabbar").outerHeight()
				  - $("#footer").outerHeight()
				  - ($.browser.msie ? 30 : 48);
			$("#container").height(h);
		});
		/**
		 * 设置标签页
		 */
		var lastActiveIndex;
		var tabs, contents;
		function tabClick(tab){
			var index = tab.index();
			if (index == lastActiveIndex) return;
			tab.addClass('tab-active');
			tabs.eq(lastActiveIndex).removeClass('tab-active');
			contents.eq(index).toggle();
			contents.eq(lastActiveIndex).toggle();
			lastActiveIndex = index;
		}
		
		//给引用的书籍添加链接
		function markBookRefers(){
			var refer = '<a href="view!bookDetail.action?bookId={}">{}</a>';
			var container = $("#container");
			var url = "view!findBookRefers.action?bookId=" + $("#bookId").val();
			$.getJSON(url, function(data){
				if (!data || ! data instanceof Array) return;
				for (var i = 0; i < data.length; i ++){
					var result = refer.replace('{}', data[i].id).replace('{}', data[i].name);
					var reg = new RegExp('《' + data[i].name + '》', 'g');
					container.html(container.html().replace(reg, '《' + result + '》'));
				}
				//必须在添加链接后才能设置标签页，否则有误。（原因未明……）
				initTabs();
			});
		}
		
		function initTabs(){
			tabs = $('#tabbar').children();
			contents = $('#container').children();
			tabs.click(function(e){
				tabClick($(this));
			});
			tabs.first().click();
		}
		
	</script>
</head>
<body style="text-align:center;margin-top:2px;overflow:hidden;margin:8px;">
	<input type="hidden" id="bookId" value="<s:property value="book.id"/>">
	<div>
		<s:if test="book != null">
		<div id="head" style="width:auto;">
			<div style="font-size:14px;font-family:仿宋;">
				<s:property value="bookType.name.substring(bookType.name.indexOf('、')+1)"/>
			</div>
			<div style="font-size:22px;font-weight:bold;margin:8 0;"><s:property value="book.name"/></div>
			<s:if test="book.name2.length()>0">
			<div style="margin-bottom:5px;font-size:14px;color:#666;">又名：<s:property value="book.name2"/></div>
			</s:if>
			<div style="color:#336600;">
				<span style="font-weight:bold;"><s:property value="book.author"/></span>
				<s:if test="book.source.length()>0">
				<span>见<s:property value="book.source"/></span>
				</s:if>
				<span><s:property value="book.rolls"/></span>
			</div>
		</div>
		<div id="tabbar">
			<s:if test="book.aboutAuthor.length()>0">
				<div class="tab">作者简介</div>
			</s:if>
			<s:if test="book.abstract_.length()>0">
				<div class="tab">内容提要</div>
			</s:if>
			<s:if test="book.academicFeatures.length() > 0">
				<div class="tab">学术特点</div>
			</s:if>
			<s:if test="book.preface.length() > 0">
				<div class="tab">序跋</div>
			</s:if>
			<s:if test="book.chorography.length() > 0">
				<div class="tab">地方志</div>
			</s:if>
			<s:if test="book.holdings.length() > 0">
				<div class="tab">现存版本与馆藏</div>
			</s:if>
			<s:if test="book.comment.length() > 0">
				<div class="tab">按语</div>
			</s:if>
		</div>
		<div id="container">
			<s:if test="book.aboutAuthor.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.aboutAuthor.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.abstract_.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.abstract_.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.academicFeatures.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.academicFeatures.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.preface.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.preface.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.chorography.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.chorography.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.holdings.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.holdings.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
			<s:if test="book.comment.length() > 0">
				<div style="display:none;">
					<s:iterator value="book.comment.split('\n')">
						　　<s:property value="top"/><br/>
					</s:iterator>
				</div>
			</s:if>
		</div>
		</s:if>
		<s:else>
			<div style="margin-top:80px;">
				&lt;书籍不存在&gt;
			</div>
		</s:else>
	</div>
	<div id="footer" style="text-align:center;padding-top:10px;">
		【<a class="a1" href="#" onclick="parent.$.fancybox.close();return false;">关&nbsp;闭</a>】
	</div>
</body>
</html>